pub fn binary_2_decimal(n: i32) -> i32 {
  let mut decimal = 0;
  let mut base = 1;
  let mut temp = n;
  while temp > 0 {
    let last_digit = temp % 10;
    temp = temp / 10;
    decimal += last_digit * base;
    base = base * 2;
  }
  decimal
}

pub fn decimal_2_binary(n: i32) -> i32 {
  let mut binary = 0;
  let mut base = 1;
  let mut temp = n;
  while n > 0 {
    let last_digit = temp % 2;
    temp = temp / 2;
    binary += last_digit * base;
    base = base * 10;
  }
  binary
}
